﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace pigs
{
    public class CrossHair
    {
        //how fast does the aimer move?
        public float Speed;

        // Animation representing the aimer
        public Texture2D Texture;

        // Position of the aimer
        public Vector2 Position;

        //initialze the aimer
        public void Initialize(Texture2D texture, Vector2 position)
        {
            Texture = texture;
            Position = position;
            Speed = 25;
        }

        // Get the width of the aimer
        public int Width
        {
            get { return Texture.Width; }
        }

        // Get the height of the aimer
        public int Height
        {
            get { return Texture.Height; }
        }

        public void Update(GamePadState currentGamePadState)
        {
            //update based off right thumbstick of game pad
            Position.X += currentGamePadState.ThumbSticks.Right.X * Speed;
            Position.Y -= currentGamePadState.ThumbSticks.Right.Y * Speed;
        }

        public void Update(KeyboardState currentKeyboardState)
        {
            // update from keyboard arrow keys
            if (currentKeyboardState.IsKeyDown(Keys.Left))
            {
                Position.X -= Speed;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Right))
            {
                Position.X += Speed;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Down))
            {
                Position.Y += Speed;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Up))
            {
                Position.Y -= Speed;
            }
        }


        //draw the aimer
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Position, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
        }
    }
}
